Processing Instruction
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
top
Processing instructions are exposed in the Document Object Model as Node.PROCESSING_INSTRUCTION_NODE, and they can be used in XPath and XQuery with the 'processing-instruction()' command.
Contents
• Syntax
• Examples
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Syntax
An XML processing instruction is enclosed within <? and ?>, and contains a target and optionally some content, which is the node value, that cannot contain the sequence ?>.cite-ref-4[4]
<?PITarget PIContent?>
The XML Declaration at the beginning of an XML document (shown below) is another example of a processing instruction,cite-ref-5[5] however it may not technically be considered one.cite-ref-nutshell-6-0[6]
<?xml version="1.0" encoding="UTF-8" ?>
Examples
The most common use of a processing instruction is to request the XML document be rendered using a stylesheet using the 'xml-stylesheet' target, which was standardized in 1999.cite-ref-7[7] It can be used for both XSLT and CSS stylesheets.
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<?xml-stylesheet type="text/css" href="style.css"?>
A draft specification for Robots exclusion standard rules inside XML documents uses processing instructions.cite-ref-9[9]
References
cite-note-22. ↑ Comparison of SGML and XML; World Wide Web Consortium Note, 15 December 1997
cite-note-55. ↑ "XML 1.0 - slide "Processing Instructions (PIs)"". www.w3.org. Retrieved 2023-02-08.
cite-note-77. ↑ "Associating Style Sheets with XML documents 1.0 (Second Edition)".
cite-note-88. ↑ "Part 2. FO Processing Instruction Reference".
cite-note-99. ↑ "Robots Processing Instruction Homepage". Archived from the original on 2010-09-21. Retrieved 2010-08-18.
External links
• XML specification section: Processing Instructions
• XSLT FAQ: Processing Instructions, Dave Pawson
• xslt:processing-instruction, Mozilla